function deepClone(obj = {}) {
    if (typeof obj === null || typeof obj !== 'object') {
        return obj
    }
    let res;
    if (obj instanceof Array) {
        res = []
    } else {
        res = {}
    }
    for (let key in obj) {
        res[key] = deepClone(obj[key])
    }
    return res
}

let obj = {
    a: 1,
    b: 2,
    c: {
        d: 3
    }
}

let obj2 = deepClone(obj);
obj2.c.d = 5

console.log(obj.c.d, obj2.c.d)